package com.example.util;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;

import android.app.Activity;

public class PubMethod 
{
    static Activity activity;
	public PubMethod()
	{
	}
	public PubMethod(Activity activity)
	{
		this.activity=activity;
	}

	public static  String loadFromFile(String fileName)
	{
		String result=null;
		try
		{
		    InputStream  fin=(InputStream ) activity.getAssets().open(Constant.ADD_PRE+fileName);
    	    int lenght = fin.available();
    	    byte[] buff=new byte[lenght];
    	    
			fin.read(buff);
    		fin.close();
    		result=new String(buff,"UTF-8"); 
 
    		result=result.replaceAll("\\r\\n","");
		}
		catch(Exception e)
		{
			System.out.println("file:"+fileName);

		}
		return result;
	}

	public static  String loadFromFileZ(String fileName)
	{
		String result=null;
		try
		{
			
			 InputStream  fin=(InputStream ) activity.getAssets().open(Constant.ADD_PRE+fileName);
	    	 int lenght = fin.available();
	    	 byte[] buff=new byte[lenght];		
			
    		fin.read(buff);
    		fin.close();
    		result=new String(buff,"UTF-8"); 
    		result=result.replaceAll("\\r\\n","\n");
		}
		catch(Exception e)
		{
			System.out.println("file"+fileName);
		
		}
		return result;
	}
}
